<?php
/**
 * Created by PhpStorm.
 * User: wx:wenyi2048
 * Date: 2022/3/18 0018
 * Time: 09:20
 */

namespace app\admin\controller\mk;
/*发票管理*/
\think\Loader::import('controller/Controller', \think\Config::get('traits_path'), EXT);

use app\admin\Controller;
use app\common\service\InvoicesService;
use app\common\service\OptionsService;
use app\common\service\OrdersService;

class Invoices extends Controller
{
    use \app\admin\traits\controller\Controller;
    public function index()
    {
        $param = $this->request->param();
        $service = new InvoicesService();//数据处理
        $service->searchPage($this->view,$param);
        return $this->view->fetch();
    }

    public function beforeEdit()
    {
        $orderId = $this->request->param('order_id');
        $oService = new OrdersService();
        $result = $oService->getOrderGoods($orderId);
        $this->view->assign('order',$result);
    }

    /**
     * 确认开票
     */
    public function billing()
    {
        $id = $this->request->param('id');//发票id
        //var_dump($id);die();
        if(empty($id)) return ajax_return_adv_error('信息丢失！');
        $iService = new InvoicesService();
        if(!$iService->billing($id)) return ajax_return_adv_error('开票失败，可能已经处理！');
        return ajax_return_adv('操作成功');
    }
}